import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ParkCouponVO, ParkCouponForm, ParkCouponQuery } from '@/api/park/parkCoupon/types';

/**
 * 查询优惠劵列表
 * @param query
 * @returns {*}
 */

export const listParkCoupon = (query?: ParkCouponQuery): AxiosPromise<ParkCouponVO[]> => {
  return request({
    url: '/park/parkCoupon/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询优惠劵详细
 * @param couponId
 */
export const getParkCoupon = (couponId: string | number): AxiosPromise<ParkCouponVO> => {
  return request({
    url: '/park/parkCoupon/' + couponId,
    method: 'get'
  });
};

/**
 * 新增优惠劵
 * @param data
 */
export const addParkCoupon = (data: ParkCouponForm) => {
  return request({
    url: '/park/parkCoupon',
    method: 'post',
    data: data
  });
};

/**
 * 修改优惠劵
 * @param data
 */
export const updateParkCoupon = (data: ParkCouponForm) => {
  return request({
    url: '/park/parkCoupon',
    method: 'put',
    data: data
  });
};

/**
 * 删除优惠劵
 * @param couponId
 */
export const delParkCoupon = (couponId: string | number | Array<string | number>) => {
  return request({
    url: '/park/parkCoupon/' + couponId,
    method: 'delete'
  });
};
